/**   
 * Copyright © 2016 北京之洲科技有限责任公司. All rights reserved.
 * 
 * @Title: ZLFKDaoOfAutoHome.java 
 * @Prject: carfactory
 * @Package: com.zizo.autohome.bbs.zlfk.dao 
 * @Description: 
 * @author: Alexis  
 * @email heyan0227@outlook.com
 * @date: 2016年8月16日 下午6:10:54 
 * @version: V1.0   
 */
package com.zizo.autohome.bbs.zlfk.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: ZLFKDaoOfAutoHome
 * @Description:
 * @author: Alexis
 * @date: 2016年8月16日 下午6:10:54
 */
public class ZLFKDaoOfAutoHome {
	private Connection conn;
	private Connection core;

	public List<String> getTables() {
		List<String> list = new ArrayList<>();
		Statement st = null;
		ResultSet rs = null;
		String sql = "SHOW TABLES";
		try {
			st = core.createStatement();
			rs = st.executeQuery(sql);
			while (rs.next()) {
				if (rs.getString(1).matches("qczj_bbs_[aco]_\\d{1,}")) {
					list.add(rs.getString(1).substring(9).replace("_", "-"));
				}
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}

	public ZLFKDaoOfAutoHome(Connection conn, Connection core) {
		super();
		this.conn = conn;
		this.core = core;
	}

	public void insertID(String id) {
		PreparedStatement ps = null;
		String sql = "Replace INTO quality(bbs_id) Values(?)";
		try {
			ps = conn.prepareStatement(sql);
			ps.setString(1, id);
			ps.executeUpdate();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}
